package cn.mafangui.hotel.controller.worker;

import cn.mafangui.hotel.entity.RoomType;
import cn.mafangui.hotel.entity.User;
import cn.mafangui.hotel.entity.Worker;
import cn.mafangui.hotel.entity.echarsEntity.Pie;
import cn.mafangui.hotel.enums.ExceptionEnum;
import cn.mafangui.hotel.exception.HotelException;
import cn.mafangui.hotel.response.AjaxResult;
import cn.mafangui.hotel.response.ResponseTool;
import cn.mafangui.hotel.service.WorkerService;
import cn.mafangui.hotel.utils.AssertUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: kalpa
 * @date: 2022/4/4
 * @version: 1.0
 * Description: 操作员的个人信息
 */

@RestController
@RequestMapping(value = "/op")
public class OpController {
    @Autowired
    WorkerService workerService;

    @ApiOperation("获取个人信息")
    @GetMapping("/profile")
    public AjaxResult profile(HttpServletRequest request) throws HotelException {
        Integer userId = (Integer) request.getSession().getAttribute("userId");
        Worker worker = workerService.selectById(userId);
        AssertUtils.assertNotNull(worker, ExceptionEnum.WORKER_NOT_FOUND);
        worker.setPassword(null);

        return ResponseTool.success(worker);
    }
}
